var express = require('express');
var router = express.Router();
let upload = require("../utils/multer");

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

/**
 * 上传图片的接口
 */
// @ResponseBody
router.post("/upload", upload.array('file'), (req, res) => {
  //如果图片上传成功  返回图片上传的地址
  res.json({
    code: 200,
    url: "/uploads/" + req.files[0].filename,
  })
})
module.exports = router;
